package edu.xmut.factory.simplefactory.order;

import edu.xmut.factory.simplefactory.pizza.Pizza;

import java.util.Objects;

/**
 * @author 朔风
 * @date 2024-02-17 13:08
 */
public class OrderPizza {

    private String orderType;
    private SimpleFactory simpleFactory;


    public void setFactory(SimpleFactory simpleFactory) {
        this.simpleFactory = simpleFactory;
    }

    public void setOrderType(String orderType) {
        Pizza pizza = simpleFactory.createPizza(orderType);
        if (Objects.nonNull(pizza)) {
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } else {
            System.out.println("订购失败");
        }
    }


}
